
package com.cskaoyan.shiro;



import org.apache.shiro.web.session.mgt.DefaultWebSessionManager;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * @author heyyon
 */
public class CustomSessionManager extends DefaultWebSessionManager {

    @Override
    protected Serializable getSessionId(ServletRequest request, ServletResponse response) {
        HttpServletRequest servletRequest=(HttpServletRequest)request;
        String sessionId = servletRequest.getHeader("X-cskaoyan-mall-Admin-Token");
        if (sessionId != null && !"".equals(sessionId)) {
            System.out.println("sessionId in get-X-cs"+sessionId);
            return sessionId;
        }
        Serializable sessionId1 = super.getSessionId(servletRequest, response);
        System.out.println(servletRequest.getRequestURI());
        System.out.println(sessionId1+" in manager");
        return sessionId1; 
    }
}

